<?php
/*
	生成验证码图片，并记录到数据库中
*/


//$sitekey = $_GET['sitekey'];
//$sessionid = $_GET['sessionid'];
$checkcode = '百度搜索';
$dir = dirname(__FILE__);
//exit($dir);
$res = imagecreatetruecolor(200, 40);
$white = imagecolorallocate($res ,255, 255, 255);
imagefilledrectangle($res, 0, 0, 200, 40, $white);

foreach(str_split($checkcode, 3) as $key => $item){
	imagettftext($res, 14, rand(-10,10), 5 + $key * 14 + rand(-5,5), 20, imagecolorallocate($res, 0, 0, 255), $dir.'/song.ttc', $item);
}


/*
for($i=0, $l=strlen($checkcode); $i<$l; $i += 3){
	
}
*/

//function output_handler($img){
	header('Content-type: image/png');
//	header('Content-Length: ' . strlen($img));
//}

//ob_start("output_handler");
imagepng($res);
//ob_end_flush();

